package cn.iocoder.yudao.module.erp.dal.mysql.finance.bankstatementitem;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.finance.bankstatementitem.vo.BankStatementItemPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.finance.bankstatement.BankStatementDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.finance.bankstatementitem.BankStatementItemDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 银行流水明细 Mapper
 * @author 天使管理员
 */
@Mapper
public interface BankStatementItemMapper extends BaseMapperX<BankStatementItemDO> {

    default PageResult<BankStatementItemDO> selectPage(BankStatementItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BankStatementItemDO>()
                .betweenIfPresent(BankStatementItemDO::getRecordDate, reqVO.getRecordDate())
                .eqIfPresent(BankStatementItemDO::getDepartment, reqVO.getDepartment())
                .eqIfPresent(BankStatementItemDO::getExpenseItem, reqVO.getExpenseItem())
                .eqIfPresent(BankStatementItemDO::getSupplier, reqVO.getSupplier())
                .eqIfPresent(BankStatementItemDO::getFleet, reqVO.getFleet())
                .eqIfPresent(BankStatementItemDO::getCardId, reqVO.getCardId())
                .orderByDesc(BankStatementItemDO::getId));
    }

    default PageResult<BankStatementItemDO> selectListByCardId(BankStatementItemPageReqVO reqVO){
        return selectPage(reqVO, new LambdaQueryWrapperX<BankStatementItemDO>()
                .eqIfPresent(BankStatementItemDO::getCardId, reqVO.getCardId())
                .betweenIfPresent(BankStatementItemDO::getRecordDate, reqVO.getRecordDate())
                .eqIfPresent(BankStatementItemDO::getSupplier, reqVO.getSupplier())
                .eqIfPresent(BankStatementItemDO::getFleet, reqVO.getFleet())
                .likeIfPresent(BankStatementItemDO::getRemark, reqVO.getAbstractInfo())
                .orderByDesc(BankStatementItemDO::getId));
    };

    default int deleteByCardId(String cardId){
        return delete(BankStatementItemDO::getCardId, cardId);
    };
}